<?php

namespace backend\models;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\models\TaozhuangPos;

class TaozhuangPosSearch extends TaozhuangPos
{
    public function rules()
    {
        // only fields in rules() are searchable
        return [
            [['tzid','item_id'], 'integer'],
            [['tzid','item_id'], 'safe'],
        ];
    }

    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    public function search($params)
    {
        $query = TaoZhuangPos::find();

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        // load the search form data and validate
        if (!($this->load($params) && $this->validate())) {
            return $dataProvider;
        }

        // adjust the query by adding the filters
        $query->andFilterWhere(['tzid' => $this->tzid])
              ->andFilterWhere(['item_id' => $this->item_id]);
              
        

        return $dataProvider;
    }
}